package com.ruoyi.web.controller.media;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.media.service.IMediaDashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 广电用户仪表盘Controller
 */
@RestController
@RequestMapping("/media/dashboard")
public class MediaDashboardController extends BaseController {

    @Autowired
    private IMediaDashboardService mediaDashboardService;

    /**
     * 获取仪表盘数据
     */
    @GetMapping("/data")
    public AjaxResult getDashboardData() {
        return AjaxResult.success(mediaDashboardService.getDashboardData());
    }

    /**
     * 刷新仪表盘数据
     */
    @PostMapping("/refresh")
    public AjaxResult refreshDashboardData() {
        return AjaxResult.success(mediaDashboardService.refreshDashboardData());
    }

    /**
     * 根据时间范围获取仪表盘数据
     */
    @GetMapping("/data/date-range")
    public AjaxResult getDashboardDataByDateRange(
            @RequestParam String startDate,
            @RequestParam String endDate) {
        return AjaxResult.success(mediaDashboardService.getDashboardDataByDateRange(startDate, endDate));
    }
}